package jy.game.components.map;


import java.util.List;

import jy.game.JyCondition;
import jy.game.tools.Tools;
import wx.xml.simpleframework.xml.Attribute;
import wx.xml.simpleframework.xml.Element;
import wx.xml.simpleframework.xml.ElementList;
import wx.xml.simpleframework.xml.Root;

@Root(name = "event")
public class JyMapEvent {
    @Attribute public                                      String            type;
    @Attribute public                                      String            value;
    @Attribute public                                      String            image;
    @Attribute(name = "probability") public                int               probabilityValue;
    @Attribute public                                      int               lv = -1;
    @Attribute public                                      String            description;
    @Attribute(name = "repeat") public                     String            repeatValue;
    @ElementList(name = "condition", inline = true) public List<JyCondition> conditions;

    // (get) Token: 0x06000432 RID: 1074 RVA: 0x0002D768 File Offset: 0x0002B968
    // [XmlIgnore]
    public int probability() {
        {
            int num = this.probabilityValue;
            int result;
            if (num == 0) {
                result = 100;
            } else {
                int num2 = this.probabilityValue;
                result = num2;//+ MapUI.fjtl;
            }
            return result;
        }
    }

    // (get) Token: 0x06000433 RID: 1075 RVA: 0x00004573 File Offset: 0x00002773
    public boolean IsRepeatOnce() {
        {
            return this.repeatValue == "once";
        }
    }

    // (get) Token: 0x06000434 RID: 1076 RVA: 0x0002D7A0 File Offset: 0x0002B9A0
    // [XmlIgnore]
    public boolean IsActive() {
        {
//                if (this.IsRepeatOnce() && RuntimeData.Instance.IsStoryFinished(this.value)) {
//                    return false;
//                }
            if (!Tools.probabilityTest(probability() / 100.0)) {
                return false;
            }
            for (JyCondition condition : this.conditions) {
                if (!condition.IsTrue()) {
                    return false;
                }
            }
            return true;
        }
    }
}